﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace LManager
{
    public static class LanguageManager
    {
        public static XDocument Document { get; set; }

        public static string GetElementValue(string value)
        {
            string[] pts = value.Split(new []{"->"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
            XElement element = Document.Root;
            foreach (string str in pts)
            {
                element = element.Element(str);
            }
            return element.Value;
        }

        public static string GetElementAttribute(string value)
        {
            List<string> pts = value.Split(new []{"->"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries).ToList();
            string attribute = pts.Last();
            pts.Remove(pts.Last());
            XElement element = Document.Root;
            foreach (string str in pts)
            {
                element = element.Element(str);
            }
            return element.Attribute(attribute).Value;
        }
    }
}
